#pragma once
#ifndef __SHADERPROGRAM_H__
#define __SHADERPROGRAM_H__

#include "Utility.h"

#include "../util/PreDeclare.h"
#include "../util/D3DCommon.h"
#include "ShaderObject.h"

namespace WindGE
{
	class WIND_CORE_API ShaderProgram : public std::enable_shared_from_this<ShaderProgram>
	{
	public:
		ShaderProgram();
		~ShaderProgram();

		bool attach_shader_object(RenderDevicePtr renderDevice, EShaderType type, 
			const std::string& fileName, const std::string& funcName, const std::string& profile);

		bool attach_cbuffer(const std::string& bufferName, ConstantBufferPtr cbuffer);
		bool attach_texres(const std::string& texresName, TextureResourcePtr texres);
		bool attach_texsampler(const std::string& texSamplerName, TextureSamplerPtr texSampler);
		bool attach_viewtarget(const std::string& viewTargetName, ShaderViewTargetPtr viewTarget);

		void bind();
		void unbind();

		void bind_constant_buffer(const std::string& name, void* data);
		void bind_texture_resource(const std::string& name, TexturePtr texture);

	private:
		std::unordered_map<std::string, ShaderObjectPtr>			shader_object_mapping_;
		std::unordered_map<std::string, ShaderObjectPtr>::iterator	shader_object_iter_;

		std::unordered_map<std::string, ConstantBufferPtr>			constant_buffer_mapping_;
		std::unordered_map<std::string, TextureResourcePtr>			texture_resource_mapping_;
		std::unordered_map<std::string, TextureSamplerPtr>			texture_sampler_mapping_;
		std::unordered_map<std::string, ShaderViewTargetPtr>		view_target_mapping_;
	};

}//end namespace WindGE

#endif //__SHADERPROGRAM_H__

